package com.rockcent.mall.lib.domain;

import com.rockcent.common.domain.IDEntityMall;
import com.rockcent.common.utils.RDigestUtils;
import com.rockcent.mall.lib.domain.enumclass.GiftPacketStatus;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Random;

/**
 * Created by DK on 16/10/8.
 * 礼包实体
 */
@Entity
@Table(name = "gift_packet")
@DynamicInsert(value = true)
@DynamicUpdate(value = true)
public class MerchantGiftPacket extends IDEntityMall {

    /** 分销礼包唯一的识别码 */
    @Column(columnDefinition = "varchar(100) comment '分销礼包唯一的识别码'")
    private Long marketId;

    /** 礼包标题 */
    @Column(columnDefinition = "varchar(255) comment '礼包标题'")
    private String name;

    /** 广告封面 */
    @Column(columnDefinition = "text comment '广告封面'")
    private String coverUrl;

    /** 出售开始时间 */
    @Column(columnDefinition = "DATETIME comment '出售开始时间'")
    private Date dateEnabled;

    /** 出售结束时间 */
    @Column(columnDefinition = "DATETIME comment '出售结束时间'")
    private Date dateDisabled;

    /** 礼包介绍 */
    @Column(columnDefinition = "MEDIUMTEXT comment '礼包介绍'")
    private String intro;

    /** 分享返利 */
    @Column(columnDefinition = "DECIMAL(30,10) comment '分享返利'")
    private BigDecimal shareFee = BigDecimal.ZERO;

    /** 总价 */
    @Column(columnDefinition = "DECIMAL(30,10) comment '总价'")
    private BigDecimal basePrice = BigDecimal.ZERO;

    /** 礼包价 */
    @Column(columnDefinition = "DECIMAL(30,10) comment '礼包价'")
    private BigDecimal sellPrice = BigDecimal.ZERO;

    @Column(columnDefinition = "varchar(30) comment '礼包状态 S1_DRAFTED(\"草稿\"), S2_SELLING(\"已上架\"), S3_UNLOAD(\"已下架\"), S4_SOLDOUT(\"已售完\"), S5_FINISHED(\"已结束\")'")
    @Enumerated(EnumType.STRING)
    private GiftPacketStatus status;

    /** 是否共享营销 */
    @Column(columnDefinition = "bit comment '是否共享营销'")
    private Boolean isRecommend = false;

    /** 商家ID */
    @Column(columnDefinition = "bigint comment '商家ID'")
    private Long merchantId;

    /** 商城ID */
    @Column(columnDefinition = "bigint comment '商城ID'")
    private Long mallId;

    /** 商家名称 */
    @Column(columnDefinition = "varchar(255) comment '商家名称'")
    private String merchantName;

    @Column(columnDefinition = "DECIMAL(30,10) comment '分销佣金'")
    private BigDecimal resellFee = BigDecimal.ZERO;

    @Column(columnDefinition = "varchar(255) comment '产品礼包推广二维码图片路径'")
    private String promoteUrl;

    @Column(columnDefinition = "varchar(255) comment 'C端访问URL'")
    private String cAccessUrl;

    public static final String CHECK_NAME_IS_NOT_NULL = "礼包标题 不能为空";
    public static final String CHECK_COVER_URL_IS_NOT_NULL = "礼包广告图片 不能为空";
    public static final String CHECK_DATE_ENABLE_IS_NOT_NULL = "礼包开始时间 不能为空";
    public static final String CHECK_DATE_DISABLE_IS_NOT_NULL = "礼包结束时间 不能为空";
    public static final String CHECK_BASE_PRICE_IS_NOT_NULL = "礼包主产品 不能为空";
    public static final String CHECK_SELL_PRICE_IS_NOT_NULL = "礼包主产品 不能为空";
    public static final String CHECK_MASTER_PRODUCT_IS_NOT_NULL = "礼包主产品 不能为空";
    public static final String CHECK_RECOMMEND_IS_NOT_NULL= "是否共享营销 不能为空  默认false";
    public static final String GIFT_PACKET_FINISHED = "产品礼包已经过期";
    public static final String GIFT_PACKET_DRAFTED = "产品礼包处于草稿状态";
    public static final String GIFT_PACKET_UNLOAD = "产品礼包已下架";
    public static final String GIFT_PACKET_SOLDOUT = "产品礼包已售完";
    public static final String GIFT_PACKET_SELF = "不能销售自己产品礼包";

    public Long getMarketId() {
        return marketId;
    }

    public void setMarketId(Long marketId) {
        this.marketId = marketId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getCoverUrl() {
        return coverUrl;
    }

    public void setCoverUrl(String coverUrl) {
        this.coverUrl = coverUrl;
    }

    public Date getDateEnabled() {
        return dateEnabled;
    }

    public void setDateEnabled(Date dateEnabled) {
        this.dateEnabled = dateEnabled;
    }

    public Date getDateDisabled() {
        return dateDisabled;
    }

    public void setDateDisabled(Date dateDisabled) {
        this.dateDisabled = dateDisabled;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public BigDecimal getShareFee() {
        return shareFee;
    }

    public void setShareFee(BigDecimal shareFee) {
        this.shareFee = shareFee;
    }

    public BigDecimal getBasePrice() {
        return basePrice;
    }

    public void setBasePrice(BigDecimal basePrice) {
        this.basePrice = basePrice;
    }

    public BigDecimal getSellPrice() {
        return sellPrice;
    }

    public void setSellPrice(BigDecimal sellPrice) {
        this.sellPrice = sellPrice;
    }

    public GiftPacketStatus getStatus() {
        return status;
    }

    public void setStatus(GiftPacketStatus status) {
        this.status = status;
    }

    public Boolean getRecommend() {
        return isRecommend;
    }

    public void setRecommend(Boolean recommend) {
        isRecommend = recommend;
    }

    public Long getMerchantId() {
        return merchantId;
    }

    public void setMerchantId(Long merchantId) {
        this.merchantId = merchantId;
    }

    public Long getMallId() {
        return mallId;
    }

    public void setMallId(Long mallId) {
        this.mallId = mallId;
    }

    public String getMerchantName() {
        return merchantName;
    }

    public void setMerchantName(String merchantName) {
        this.merchantName = merchantName;
    }

    public BigDecimal getResellFee() {
        return resellFee;
    }

    public void setResellFee(BigDecimal resellFee) {
        this.resellFee = resellFee;
    }

    public String getPromoteUrl() {
        return promoteUrl;
    }

    public void setPromoteUrl(String promoteUrl) {
        this.promoteUrl = promoteUrl;
    }

    public String getcAccessUrl() {
        return cAccessUrl;
    }

    public void setcAccessUrl(String cAccessUrl) {
        this.cAccessUrl = cAccessUrl;
    }

    @Override
    public String toString() {
        return "MerchantGiftPacket{" +
                "id=" + id +
                ", marketId=" + marketId +
                ", dateCreated=" + dateCreated +
                ", name='" + name + '\'' +
                ", lastUpdated=" + lastUpdated +
                ", coverUrl='" + coverUrl + '\'' +
                ", dateEnabled=" + dateEnabled +
                ", isDelete=" + isDelete +
                ", version=" + version +
                ", dateDisabled=" + dateDisabled +
                ", intro='" + intro + '\'' +
                ", shareFee=" + shareFee +
                ", basePrice=" + basePrice +
                ", sellPrice=" + sellPrice +
                ", status=" + status +
                ", isRecommend=" + isRecommend +
                ", merchantId=" + merchantId +
                ", mallId=" + mallId +
                ", merchantName='" + merchantName + '\'' +
                ", resellFee=" + resellFee +
                ", promoteUrl='" + promoteUrl + '\'' +
                ", cAccessUrl='" + cAccessUrl + '\'' +
                '}';
    }
}
